There's no built-in password reset functionality in MDriven Turnkey. Add this pattern to your model that you can adapt as needed.
If you use the default package for login, the ASPNETIdentity package, this package will extend your model with the following:
- A reset password page that you can create an action to go to. This page should not have any access groups.
- A server-side ViewModel that runs every 20 seconds and sends emails with reset instructions to your users. Remember to set the Turnkey/MDrivenServer's email server settings.
- A page for the user to set the password. This page also has information for the user about expired reset tickets and sending new tickets in those circumstances.
Usage
- Merge the pattern into your model from the TK Live View
- Set the PasswordReset package's "Default superclass" if you want that.
- Make sure you have an email server set up and update the email settings of the MDriven Server.
- Create an action that opens the "ResetPasswordPage" ViewModel.
- Open the SS_ResetPassword ViewModel and update the from Column expression to the email of the sender string.
Email Settings
Goto your MDriven Server control panel -> Running -> then Model and edit fields for the email settings.
ServerSide ViewModel to Send Emails
ResetPasswordTicket
Attributes
Expires
: DateTime?
This is the expiring DateTime of the ResetPasswordTicket.
ResetAuthorizationCode
: String?
This is the token used for identifying user's reset password tickets. It is unique for every ticket.
ResetLog
: Text?
This is for tracking the state changes of the password reset request process.
ResetPasswordURL
: String?
This is the URL used to reset the password.
Sent
: DateTime?
This is the DateTime the email that contains the password reset url was sent to the user.
vNewPassword
: String?
Captures the new password to be set for the user.
vNewPasswordConfirm
: String?
Copy of password to confirm new password.
/CanNewTicketBeSent
: Boolean
Derived attribute to determine if a new password reset ticket can be sent by checking if they are no existing tickets waiting to sent or tickets that have been sent.
/IsValid
: Boolean
Derived attribute to check ticket has not yet expired.
/ShowDoneUI
: Boolean
Derived attribute used to show the DONEUI when password has been reset.
/ShowResetUI
: Boolean
Derived attribute used to show Reset password UI with new password fields.
Methods
AddToLog
Arg: aText - Text to add to log
This is used to add content to the ResetLog attribute.
GetExpiresInMinutes
: Integer
This is used to get the number of minutes it will take for the reset password ticket to expire.
OnCreate
This is used to set the ResetAuthorizationCode, ResetPasswordURL and Expires attributes. Default expiry time is 120 minutes. Adjust this to your suiting.
OnStateChange
This is used to capture state changes stored in the ResetLog attribute.
SysUser
Methods
GetResetPasswordTicket
: ResetPasswordTicket
Triggers the ResetPasswordTicket State Machine to expire any password reset requests are past their expiry time.
This method returns the user's ResetPasswordTicket that has been sent if any is available otherwise creates a new ResetPasswordTicket
HashPassword
: String
Arg: pwd:String - password to hash
This is used to hash a user's password
SetPassword
Arg: pwd:String - new password to set
This is used to set a new PasswordHash for a user using the HashPassword method.
See also:
- SysUserAuthentication Package
- ASP.NET Identity Package
Download the model file here: Model_Examples